package cn.wolfcode.wolf2w.business.service.impl;

import cn.wolfcode.wolf2w.api.RemoteDestinationService;
import cn.wolfcode.wolf2w.api.domain.Destination;
import cn.wolfcode.wolf2w.api.domain.DestinationSearch;
import cn.wolfcode.wolf2w.business.repository.DestinationRepository;
import cn.wolfcode.wolf2w.business.service.IDestinationSearchService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 浪兎兎
 * @since 2025-06-12 15:16
 */
@Service
public class DestinationSearchServiceImpl implements IDestinationSearchService {
    @Autowired
    private RemoteDestinationService destinationService;
    @Autowired
    private DestinationRepository destinationRepository;
    @Override
    public void initSearch() {
        List<Destination> result = destinationService.list("inner").getData();
        result.forEach(destination -> {
            DestinationSearch destinationSearch = new DestinationSearch();
            BeanUtils.copyProperties(destination, destinationSearch);
            destinationRepository.save(destinationSearch);
        });
    }
}
